package com.itwang.controller;

import cn.hutool.core.lang.Validator;
import cn.hutool.core.map.MapUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itwang.entity.User;
import com.itwang.entity.dto.UserLoginDTO;
import com.itwang.entity.dto.UserTokenDTO;
import com.itwang.service.IUserService;
import com.itwang.utils.AjaxResult;
import com.itwang.utils.jwt.JwtFilter;
import com.itwang.utils.jwt.JwtUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itWang
 * @since 2024-07-30
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    IUserService userService;

    @RequiresAuthentication
    @GetMapping("/index")
    public AjaxResult index() {
        User user = userService.getById(1L);
        return AjaxResult.success(user);
    }

    @PostMapping("/save")
    public AjaxResult save(@Validated @RequestBody User user) {
        return AjaxResult.success(user);
    }

}
